<?php
require_once("init.php");

$id=$_GET['id'];
$url="http://twitter.com/statuses/show/".$id.".json";
$status=obj_to_array(get_from_twitter($url));
$screen_name=$status['user']['screen_name'];
$text=$status['text'];

//unlearn
$unlearn_from_mode = $_GET['mode'] == 'ham' ? 'spam' : 'ham';
unlearn_by_b8($screen_name . ' ' . $text, $unlearn_from_mode);

//learn
learn_by_b8($screen_name . ' ' . $text, $_GET['mode']);

//empty cache
delete_cache('all');

//return
$from = (isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : 'index.php';
header('location: '.$from);
?>